<?php
/*this include file creates the body
 *  (<option value=".... bit) of a drop down list
*  showing projects
*/
include($_SERVER['DOCUMENT_ROOT']."/f21na/inc_files/utils/dbconnection.php");
//query for all non-deleted projects
$query ="SELECT ProjectTitle, ProjectID FROM projects WHERE  Deleted != 1  ORDER BY ProjectID";
$result = $mysqli->query( $query );

//count the number of returned results
$resultCount = $result->num_rows;
echo "<option value=\"Please select...\">Please select...</option>";
//if there are some results returned create a table showing the results
if( $resultCount > 0){
	while($row = mysqli_fetch_array($result))
	{
		echo "<option value=\"{$row['ProjectID']}\">{$row['ProjectID']} - ";
		if(strlen($row['ProjectTitle']) > 30){
			echo substr($row['ProjectTitle'], 0, 28)."...";
		} else {
			echo $row['ProjectTitle'];
		}
			
		echo "</option>";
	}

}

//tidy up database connection
$mysqli->close();
?>